@import '../../stylesheets/base';
@import '../../stylesheets/variables';

.scan-results {
  .page-content {
    width: $max-content-width;
    margin: auto;
  }

  h1 {
    margin-bottom: 0.5rem;
  }
}

.scan-results__container {
  width: 100%;
  padding: 0;
  margin: 0;
  border: 1px solid lighten($raven, 50%);
  border-radius: 2px;
  box-shadow: 0 0 4px lighten($raven, 50%);
}

.scan-results__note {
  @include font-size-xs;
  color: lighten($raven, 20%);
  margin-top: $global-spacing * 2;
  margin-bottom: $global-spacing * 4;
}

.scan-results__sort-panel {
  @include font-size-sm;
  margin-bottom: 1.5rem;
  color: $raven;

  label {
    text-transform: uppercase;
    font-weight: $font-weight-bold;
  }

  button {
    cursor: pointer;
    border: none;
    border-bottom: 1px dashed lighten($raven, 40%);
    box-shadow: none;
    background: none;
    margin-left: $global-spacing;
    padding: $global-spacing * 0.5 0;
    transition: border-color 0.2s;
    color: inherit;

    &:hover {
      border-color: lighten($raven, 30%);
    }

    &:focus {
      outline: none;
    }
  }

  .scan-results__sort--selected {
    color: $pastel-green;
    border-color: $pastel-green;
  }
}

.scan-results__item {
  background: linear-gradient(
    rgba(255, 255, 255, 0) 5%,
    rgba(255, 255, 255, 1) 10%,
    rgba(255, 255, 255, 1) 90%,
    rgba(255, 255, 255, 0) 95%
  );
  display: flex;
  list-style: none;
  padding: $global-spacing * 2 $global-spacing * 2;
  align-items: center;

  & + & {
    border-top: 1px solid lighten($raven, 50%);
  }
}

.scan-results__item--total {
  background: transparentize($raven, 0.96);
}

.scan-results__item--loading {
  position: relative;
  padding: $global-spacing * 2.5 $global-spacing * 2;

  &::after {
    content: '';
    left: 0;
    top: 0;
    position: absolute;
    width: 50%;
    height: 100%;
    background: rgba(60, 60, 70, 0.04);
    animation: progress-bar 1s cubic-bezier(0.645, 0.045, 0.355, 1) alternate
      infinite;
  }
}

@keyframes progress-bar {
  from {
    transform: translateX(0%);
  }

  to {
    transform: translateX(100%);
  }
}

.scan-results__stat-container {
  flex-grow: 1;
  display: flex;
  align-items: center;
  animation: fade-in-result 0.4s;
  max-width: $global-spacing * 68;
}

.scan-results__stat-item {
  flex: 1;
}

.scan-results__item--total {
  .scan-results__stat-item {
    .stat-container__value,
    .stat-container__unit,
    .stat-container__label {
      font-weight: $font-weight-bold;
    }

    .stat-container__label {
      letter-spacing: 0.6px;
    }
  }
}

.scan-results__loading-text,
.scan-results__error-text {
  @include font-size-sm;
  flex-grow: 1;
  text-align: center;
  color: lighten($raven, 20%);
  text-transform: uppercase;
  font-weight: $font-weight-bold;
  letter-spacing: 0.5px;
}

.scan-results__error-text {
  font-family: $font-family-code;
  text-transform: none;

  summary {
    text-align: left;

    &:focus {
      outline: none;
    }
  }

  p {
    @include font-size-sm;
    font-weight: $font-weight-light;
    text-align: left;
    color: lighten($raven, 10%);
    font-family: $font-family-body;
    line-height: 1.5;
  }
}

@keyframes fade-in-result {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

$index-width: 4rem;

.scan-results__index {
  @include font-size-xl;
  font-weight: $font-weight-very-bold;
  color: lighten($raven, 50%);
  position: relative;
  width: $index-width;
}

.scan-results__name {
  position: relative;
  width: 15%;
  min-width: $global-spacing * 18;
  padding-left: $global-spacing;

  a {
    color: inherit;
  }

  .scan-results__package-version {
    color: $raven;
    font-family: $font-family-code;
  }

  .scan-results__item--total & {
    @include font-size-md;
    width: 15%;
    margin-left: $index-width;
    font-weight: $font-weight-bold;
    letter-spacing: 1px;
    text-transform: uppercase;
  }
}

.scan-results__package-name {
  .scan-results__item--error & {
    text-decoration: line-through;
  }
}
